'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  // 解构赋值
  const { router, controller } = app;
  /* newer parts: */
  router.get('/login', controller.home.login);
  router.post('/login', controller.home.doLogin);
  router.post('/logout', controller.home.logout);

  router.get('/jspang', controller.home.jspang);
  /* the next router use the controller.jspang.index
  (it means:the controller directory;the js file `jspang.js` in the dir;
  the `index`page defined in the 'jspang.js`)
  eg.you can visit the page in browser url inputer :localhost/jspangPageNameInUrl
   */
  router.get('/jspangPageNameInUrl', controller.jspang.indexPage);


  /* older parts: */
  router.get('/', controller.home.index);
  router.resources('fruits', '/fruits', controller.fruits);

  // config the method the router will guide(these methods may create page content or do some post handling)
  /* router.get('/fruits',controller.fruits.index);
  router.get('/fruits/:id',controller.fruits.getId);
  router.get('/createFruit',controller.fruits.createPage);
  router.post('/createFruit',controller.fruits.createFruit) */

};
